IS_CHOKED_FLOW
Overview
Determine if a flow is choked (critical) based on pressure ratio.
Excel Usage
=IS_CHOKED_FLOW(p_upstream, p_downstream, k_isentropic)
p_upstream(float, required): Higher, source pressure [Pa]p_downstream(float, required): Lower, downstream pressure [Pa]k_isentropic(float, required): Isentropic exponent [-]
Returns (bool): True if flow is choked (critical), False otherwise
Examples
Example 1: API 520 Example 1 - not choked
Inputs:
| p_upstream | p_downstream | k_isentropic |
|---|---|---|
| 670000 | 532000 | 1.11 |
Excel formula:
=IS_CHOKED_FLOW(670000, 532000, 1.11)
Expected output:
false
Example 2: API 520 Example 2 - choked flow
Inputs:
| p_upstream | p_downstream | k_isentropic |
|---|---|---|
| 670000 | 101000 | 1.11 |
Excel formula:
=IS_CHOKED_FLOW(670000, 101000, 1.11)
Expected output:
true
Example 3: Near critical pressure ratio
Inputs:
| p_upstream | p_downstream | k_isentropic |
|---|---|---|
| 1000000 | 500000 | 1.4 |
Excel formula:
=IS_CHOKED_FLOW(1000000, 500000, 1.4)
Expected output:
true
Example 4: High pressure ratio - definitely choked
Inputs:
| p_upstream | p_downstream | k_isentropic |
|---|---|---|
| 5000000 | 100000 | 1.4 |
Excel formula:
=IS_CHOKED_FLOW(5000000, 100000, 1.4)
Expected output:
true
Python Code
import micropip
await micropip.install(["fluids"])
from fluids.compressible import is_critical_flow as fluids_is_crit
def is_choked_flow(p_upstream, p_downstream, k_isentropic):
"""
Determine if a flow is choked (critical) based on pressure ratio.
See: https://fluids.readthedocs.io/fluids.compressible.html#fluids.compressible.is_critical_flow
This example function is provided as-is without any representation of accuracy.
Args:
p_upstream (float): Higher, source pressure [Pa]
p_downstream (float): Lower, downstream pressure [Pa]
k_isentropic (float): Isentropic exponent [-]
Returns:
bool: True if flow is choked (critical), False otherwise
"""
# Validate and convert inputs
try:
p_upstream = float(p_upstream)
except (ValueError, TypeError):
return "Invalid input: p_upstream must be a number."
try:
p_downstream = float(p_downstream)
except (ValueError, TypeError):
return "Invalid input: p_downstream must be a number."
try:
k_isentropic = float(k_isentropic)
except (ValueError, TypeError):
return "Invalid input: k_isentropic must be a number."
# Validation
if p_upstream <= 0:
return "Invalid input: p_upstream must be positive."
if p_downstream < 0:
return "Invalid input: p_downstream must be non-negative."
if k_isentropic <= 1:
return "Invalid input: k_isentropic must be greater than 1."
if p_downstream >= p_upstream:
return "Invalid input: p_downstream must be less than p_upstream."
try:
result = fluids_is_crit(P1=p_upstream, P2=p_downstream, k=k_isentropic)
return bool(result)
except Exception as e:
return f"Error: Failed to compute critical flow check: {str(e)}"